package com.qqhf.hitfood.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qqhf.common.entity.AjaxResult;
import com.qqhf.common.entity.PageEntity;
import com.qqhf.hitfood.bean.core.BaseController;
import com.qqhf.hitfood.bean.entity.StAcct;
import com.qqhf.hitfood.service.IStAcctService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@Api(tags = "S - [字典]账号状态")
@RestController
@RequestMapping("/st/acct")
public class StAcctController extends BaseController {
    @Autowired
    private IStAcctService stAcctService;

    @GetMapping("/page")
    public AjaxResult page(PageEntity pageEntity, StAcct stAcct) {
        return AjaxResult.success(stAcctService.page(pageEntity.toPage(), Wrappers.lambdaQuery(stAcct)));
    }

    @GetMapping("/list")
    public AjaxResult list(StAcct stAcct) {
        return AjaxResult.success(stAcctService.list(Wrappers.lambdaQuery(stAcct)));
    }

    @PostMapping("/add")
    public AjaxResult add(@RequestBody StAcct stAcct) {
        return AjaxResult.success(stAcctService.save(stAcct));
    }

    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody StAcct stAcct) {
        return AjaxResult.success(stAcctService.updateById(stAcct));
    }

    @DeleteMapping("/delete/{ids}")
    public AjaxResult delete(@PathVariable Integer[] ids) {
        return AjaxResult.success(stAcctService.removeByIds(Arrays.asList(ids)));
    }

    @GetMapping(value = "/detail/{id}")
    public AjaxResult detail(@PathVariable("id") Integer id) {
        return AjaxResult.success(stAcctService.getById(id));
    }
}
